package com.wjk.kylin.rpc.samples.consumer.service.impl;

import com.wjk.kylin.rpc.core.invoker.annotation.RpcReference;
import com.wjk.kylin.rpc.core.invoker.route.LoadBalance;
import com.wjk.kylin.rpc.samples.api.service.DemoService;
import com.wjk.kylin.rpc.samples.consumer.service.IndexService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author wjk
 */
@Slf4j
@Service
public class IndexServiceImpl implements IndexService {

    @RpcReference(loadBalance = LoadBalance.Route.Random)
    private DemoService demoService;

    @Override
    public String index(String name) {
        log.info("-------------------> hello name:{},start time:{}", name, System.currentTimeMillis());
        String hello = demoService.hello(name);
//        log.info("-------------------> hello,end time:{},return:{}", System.currentTimeMillis(), hello);

//        Long time = demoService.sayBye(name);
//        log.info("-------------------> bye,end time:{},return:{}", System.currentTimeMillis(), time);
        return hello;
    }
}
